From 86bda48fe181dca630941d7394b2b35be9914d50 Mon Sep 17 00:00:00 2001 From: robertl Date: Wed, 31 Aug 2005 14:45:28 +0000 Subject: [PATCH] Olaf adds support for Geonet. --- gpsbabel/Makefile | 2 +- gpsbabel/README | 11 +++++- gpsbabel/internal_styles.c | 55 +++++++++++++++++++++++++++- gpsbabel/reference/geonet-sample.gpx | 55 ++++++++++++++++++++++++++++ gpsbabel/reference/geonet-sample.txt | 10 +++++ gpsbabel/style/geonet.style | 49 +++++++++++++++++++++++++ gpsbabel/xcsv.c | 6 +++ 7 files changed, 183 insertions(+), 5 deletions(-) create mode 100644 gpsbabel/reference/geonet-sample.gpx create mode 100644 gpsbabel/reference/geonet-sample.txt create mode 100644 gpsbabel/style/geonet.style diff --git a/gpsbabel/Makefile b/gpsbabel/Makefile index f3fac011f..037069ac2 100644 --- a/gpsbabel/Makefile +++ b/gpsbabel/Makefile @@ -391,5 +391,5 @@ jeeps/gpsutil.o: jeeps/gpsutil.c jeeps/gps.h jeeps/../defs.h \ jeeps/gpsproj.h jeeps/gpsnmeafmt.h jeeps/gpsnmeaget.h shapelib/dbfopen.o: shapelib/dbfopen.c shapelib/shapefil.h shapelib/shpopen.o: shapelib/shpopen.c shapelib/shapefil.h -internal_styles.c: mkstyle.sh style/README.style style/arc.style style/csv.style style/custom.style style/dna.style style/fugawi.style style/gpsdrive.style style/gpsdrivetrack.style style/gpsman.style style/mapconverter.style style/mxf.style style/nima.style style/openoffice.style style/s_and_t.style style/saplus.style style/tabsep.style style/xmap.style style/xmapwpt.style +internal_styles.c: mkstyle.sh style/README.style style/arc.style style/csv.style style/custom.style style/dna.style style/fugawi.style style/geonet.style style/gpsdrive.style style/gpsdrivetrack.style style/gpsman.style style/mapconverter.style style/mxf.style style/nima.style style/openoffice.style style/s_and_t.style style/saplus.style style/tabsep.style style/xmap.style style/xmapwpt.style ./mkstyle.sh > internal_styles.c || (rm -f internal_styles.c ; exit 1) diff --git a/gpsbabel/README b/gpsbabel/README index c6c57083f..c8ea31061 100644 --- a/gpsbabel/README +++ b/gpsbabel/README @@ -1016,10 +1016,17 @@ THE FORMATS Intended to serve as source for number-processing applications like OpenOffice, Ploticus and others. Tab was chosen as delimiter because it is a) supported by both OpenOffice and Ploticus and - b) is not ',', so you can use 'sed -i "s/./,/g" .csv' to adapt it to - locales where ',' is used as decimal seperator. + b) is not ',', so you can use 'sed -i "s/./,/g" .csv' to adapt + it to locales where ',' is used as decimal seperator. Contributed by Tobias Minich. + GEOnet + + Input support for the GEOnet Names Server (GNS) country file + structure. Export to this format is not possible, as this format + has too many fields that we never get populated by any other format. + + DATA FILTERS GPSBabel supports data filtering. Data filters are invoked from diff --git a/gpsbabel/internal_styles.c b/gpsbabel/internal_styles.c index 4093cc952..59d773cb8 100644 --- a/gpsbabel/internal_styles.c +++ b/gpsbabel/internal_styles.c @@ -216,6 +216,57 @@ static char garmin301[] = "#EPILOGUE Epilogue Line 1\n" "#EPILOGUE Epilogue Line 2\n" ; +static char geonet[] = +"# gpsbabel XCSV style file\n" +"#\n" +"# Format: GEOnet Names Server (GNS) (http://earth-info.nga.mil/gns/html/cntry_files.html)\n" +"# Author: Olaf Klein\n" +"# Date: 08/20/2002\n" +"#\n" + +"DESCRIPTION GEOnet Names Server (GNS)\n" +"EXTENSION txt\n" + +"#\n" +"# FILE LAYOUT DEFINITIIONS:\n" +"#\n" + +"FIELD_DELIMITER TAB\n" +"RECORD_DELIMITER CRNEWLINE\n" +"BADCHARS TAB\n" +"ENCODING UTF-8\n" + +"PROLOGUE RC UFI UNI LAT LONG DMS_LAT DMS_LONG UTM JOG FC DSG PC CC1 ADM1 ADM2 DIM CC2 NT LC SHORT_FORM GENERIC SORT_NAME FULL_NAME FULL_NAME_ND MODIFY_DATE\n" + +"#\n" +"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:\n" +"#\n" +"IFIELD IGNORE, \"\", \"%s\" # RC ( http://earth-info.nga.mil/gns/html/gis_contryfiles.html )\n" +"IFIELD IGNORE, \"\", \"%s\" # UFI\n" +"IFIELD IGNORE, \"\", \"%s\" # UNI\n" +"IFIELD LAT_DECIMAL, \"\", \"%03.7f\" # LAT\n" +"IFIELD LON_DECIMAL, \"\", \"%03.7f\" # LONG\n" +"IFIELD IGNORE, \"\", \"%s\" # DMS_LAT\n" +"IFIELD IGNORE, \"\", \"%s\" # DMS_LONG\n" +"IFIELD IGNORE, \"\", \"%s\" # UTM\n" +"IFIELD IGNORE, \"\", \"%s\" # JOG\n" +"IFIELD IGNORE, \"\", \"%s\" # FC\n" +"IFIELD IGNORE, \"\", \"%s\" # DSG\n" +"IFIELD IGNORE, \"\", \"%s\" # PC\n" +"IFIELD IGNORE, \"\", \"%s\" # CC1\n" +"IFIELD IGNORE, \"\", \"%s\" # ADM1\n" +"IFIELD IGNORE, \"\", \"%s\" # ADM2\n" +"IFIELD IGNORE, \"\", \"%s\" # DIM\n" +"IFIELD IGNORE, \"\", \"%s\" # CC2\n" +"IFIELD IGNORE, \"\", \"%s\" # NT\n" +"IFIELD IGNORE, \"\", \"%s\" # LC\n" +"IFIELD IGNORE, \"\", \"%s\" # SHORT_FORM\n" +"IFIELD IGNORE, \"\", \"%s\" # GENERIC\n" +"IFIELD SHORTNAME, \"\", \"%s\" # SHORT_NAME\n" +"IFIELD DESCRIPTION, \"\", \"%s\" # FULL_NAME\n" +"IFIELD IGNORE, \"\", \"%s\" # FULL_NAME_ND\n" +"IFIELD IGNORE, \"\", \"%s\" # MOD_DATE\n" +; static char gpsdrive[] = "# gpsbabel XCSV style file\n" "#\n" @@ -686,5 +737,5 @@ static char xmapwpt[] = "IFIELD DESCRIPTION, \"\", \"%-.78s\"\n" ; #include "defs.h" -style_vecs_t style_list[] = {{ "xmapwpt", xmapwpt } , { "xmap", xmap } , { "tabsep", tabsep } , { "saplus", saplus } , { "s_and_t", s_and_t } , { "openoffice", openoffice } , { "nima", nima } , { "mxf", mxf } , { "mapconverter", mapconverter } , { "gpsman", gpsman } , { "gpsdrivetrack", gpsdrivetrack } , { "gpsdrive", gpsdrive } , { "garmin301", garmin301 } , { "fugawi", fugawi } , { "dna", dna } , { "custom", custom } , { "csv", csv } , { "arc", arc } , {0,0}}; -size_t nstyles = 18; +style_vecs_t style_list[] = {{ "xmapwpt", xmapwpt } , { "xmap", xmap } , { "tabsep", tabsep } , { "saplus", saplus } , { "s_and_t", s_and_t } , { "openoffice", openoffice } , { "nima", nima } , { "mxf", mxf } , { "mapconverter", mapconverter } , { "gpsman", gpsman } , { "gpsdrivetrack", gpsdrivetrack } , { "gpsdrive", gpsdrive } , { "geonet", geonet } , { "garmin301", garmin301 } , { "fugawi", fugawi } , { "dna", dna } , { "custom", custom } , { "csv", csv } , { "arc", arc } , {0,0}}; +size_t nstyles = 19; diff --git a/gpsbabel/reference/geonet-sample.gpx b/gpsbabel/reference/geonet-sample.gpx new file mode 100644 index 000000000..67c7af66a --- /dev/null +++ b/gpsbabel/reference/geonet-sample.gpx @@ -0,0 +1,55 @@ + + + + + + PLAUEN + Plauen + Plauen + + + PLAUEN + Plauen + Plauen + + + PLAUEN STADTKREIS + Stadtkreis Plauen + Stadtkreis Plauen + + + PLAUENERSTADTWALD + Plauener Stadtwald + Plauener Stadtwald + + + ZSCHOPAU + Zschopau + Zschopau + + + ZSCHOPAU + Zschopau + Zschopau + + + ZSCHOPEL + Zschöpel + Zschöpel + + + ZSCHOPENBERG + Zschopen-Berg + Zschopen-Berg + + + ZSCHOPENTHAL + Zschopenthal + Zschopenthal + + diff --git a/gpsbabel/reference/geonet-sample.txt b/gpsbabel/reference/geonet-sample.txt new file mode 100644 index 000000000..d6c89798e --- /dev/null +++ b/gpsbabel/reference/geonet-sample.txt @@ -0,0 +1,10 @@ +RC UFI UNI LAT LONG DMS_LAT DMS_LONG UTM JOG FC DSG PC CC1 ADM1 ADM2 DIM CC2 NT LC SHORT_FORM GENERIC SORT_NAME FULL_NAME FULL_NAME_ND MODIFY_DATE +1 -1843626 -2549662 51.0166667 13.7166667 510100 134300 VS05 NM33-01 P PPLX GM 13 N PLAUEN Plauen Plauen 1994-01-08 +1 -1843625 -2549661 50.5 12.1333333 503000 120800 TR99 NM33-04 P PPL 3 GM 13 N PLAUEN Plauen Plauen 2002-05-02 +1 -1843628 -2549664 50.5 12.1333333 503000 120800 TR99 NM33-04 A ADM3 GM 13 Chemnitz V PLAUEN STADTKREIS Stadtkreis Plauen Stadtkreis Plauen 1998-04-28 +1 -1843629 -2549666 50.5333333 12.1333333 503200 120800 TS90 NM33-04 V FRST GM 13 N PLAUENERSTADTWALD Plauener Stadtwald Plauener Stadtwald 1998-05-12 +1 -1893314 -2603706 51.1333333 13.05 510800 130300 US66 NM33-01 H STM GM 13 N ZSCHOPAU Zschopau Zschopau 1994-01-08 +1 -1893313 -2603705 50.75 13.0666667 504500 130400 US62 NM33-04 P PPL 4 GM 13 N ZSCHOPAU Zschopau Zschopau 2002-05-02 +1 -1893316 -2603708 50.8666667 12.4166667 505200 122500 US13 NM33-04 P PPL GM 15 N ZSCHOPEL Zschöpel Zschopel 1998-05-15 +1 -1893317 -2603709 50.7333333 13.0666667 504400 130400 US62 NM33-04 T HLL GM 13 N ZSCHOPENBERG Zschopen-Berg Zschopen-Berg 1994-01-08 +1 -1893318 -2603710 50.7666667 13.1 504600 130600 US62 NM33-04 P PPL GM 13 N ZSCHOPENTHAL Zschopenthal Zschopenthal 1994-01-08 diff --git a/gpsbabel/style/geonet.style b/gpsbabel/style/geonet.style new file mode 100644 index 000000000..7b7d3a15c --- /dev/null +++ b/gpsbabel/style/geonet.style @@ -0,0 +1,49 @@ +# gpsbabel XCSV style file +# +# Format: GEOnet Names Server (GNS) (http://earth-info.nga.mil/gns/html/cntry_files.html) +# Author: Olaf Klein +# Date: 08/20/2002 +# + +DESCRIPTION GEOnet Names Server (GNS) +EXTENSION txt + +# +# FILE LAYOUT DEFINITIIONS: +# + +FIELD_DELIMITER TAB +RECORD_DELIMITER CRNEWLINE +BADCHARS TAB +ENCODING UTF-8 + +PROLOGUE RC UFI UNI LAT LONG DMS_LAT DMS_LONG UTM JOG FC DSG PC CC1 ADM1 ADM2 DIM CC2 NT LC SHORT_FORM GENERIC SORT_NAME FULL_NAME FULL_NAME_ND MODIFY_DATE + +# +# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE: +# +IFIELD IGNORE, "", "%s" # RC ( http://earth-info.nga.mil/gns/html/gis_contryfiles.html ) +IFIELD IGNORE, "", "%s" # UFI +IFIELD IGNORE, "", "%s" # UNI +IFIELD LAT_DECIMAL, "", "%03.7f" # LAT +IFIELD LON_DECIMAL, "", "%03.7f" # LONG +IFIELD IGNORE, "", "%s" # DMS_LAT +IFIELD IGNORE, "", "%s" # DMS_LONG +IFIELD IGNORE, "", "%s" # UTM +IFIELD IGNORE, "", "%s" # JOG +IFIELD IGNORE, "", "%s" # FC +IFIELD IGNORE, "", "%s" # DSG +IFIELD IGNORE, "", "%s" # PC +IFIELD IGNORE, "", "%s" # CC1 +IFIELD IGNORE, "", "%s" # ADM1 +IFIELD IGNORE, "", "%s" # ADM2 +IFIELD IGNORE, "", "%s" # DIM +IFIELD IGNORE, "", "%s" # CC2 +IFIELD IGNORE, "", "%s" # NT +IFIELD IGNORE, "", "%s" # LC +IFIELD IGNORE, "", "%s" # SHORT_FORM +IFIELD IGNORE, "", "%s" # GENERIC +IFIELD SHORTNAME, "", "%s" # SHORT_NAME +IFIELD DESCRIPTION, "", "%s" # FULL_NAME +IFIELD IGNORE, "", "%s" # FULL_NAME_ND +IFIELD IGNORE, "", "%s" # MOD_DATE diff --git a/gpsbabel/xcsv.c b/gpsbabel/xcsv.c index 9cfd185d7..95f3e5d86 100644 --- a/gpsbabel/xcsv.c +++ b/gpsbabel/xcsv.c @@ -323,6 +323,12 @@ xcsv_parse_style_line(const char *sbuff) xcsv_epilogue_add(xstrdup(&sbuff[9])); } else + if (ISSTOKEN(sbuff, "ENCODING")) { + p = csv_stringtrim(&sbuff[8], "\"", 1); + cet_convert_init(p, 1); + xfree(p); + } else + if (ISSTOKEN(sbuff, "IFIELD")) { key = val = pfc = NULL; -- 2.30.2